package factory.simplefactory;

import factory.modules.AdvertisingSceen;
import factory.modules.Devices;
import factory.modules.HumanInteractionSceen;
import factory.modules.SplicingSceen;

/**
 * @author Feng
 * @date 2019/3/8 17:12
 */
public class DevicesFactory {
    public static Devices Initialize(String deviceType){
        if("AD".equals(deviceType)){
            return new AdvertisingSceen();
        }
        if("HI".equals(deviceType)){
            return new HumanInteractionSceen();
        }
        if("SP".equals(deviceType)){
            return new SplicingSceen();
        }
        return null;
    }

    public static Devices Initialize(Class<?> clazz){
        try{
            return (Devices) Class.forName(clazz.getName()).newInstance();
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        Devices devices1 = DevicesFactory.Initialize("AD");
        devices1.show();
        Devices devices2 = DevicesFactory.Initialize(HumanInteractionSceen.class);
        devices2.show();
    }
}
